{include file="public/head"}
{include file="public/left"}
<!-- content -->

<div class="main_02_r">

    <!--内容区域-->
    <div class="site_01">
        <span>当前位置：</span><a href="#">城事社</a><i>></i><a href="#">基本服务</a>
    </div>

    <div class="nrq_01">
        <div class="gg_01">
            <span class=""><a href="{:url('basic/service')}">客服</a></span><span class="on">投诉建议</span><span><a href="{:url('basic/aboutUs')}">关于我们</a></span><span><a href="{:url('basic/technical')}">技术服务</a></span>
        </div>
        <div class="gg_02">
            <div class="gg_03">

                <div class="gg_03_t">
                    <em class="fr">
                        <form method="get">
                        <input type="text" name="search" value="{$search|default=''}" placeholder="请输入关键词" class="gg_03_txt" />
                            <input type="submit" value="" class="gg_03_btn" />
                        </form>
                    </em>
                </div>

                <div class="jgsp_01">
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <th>序号</th>
                            <th>分类</th>
                            <th>标题</th>
                            <th>内容</th>
                            <th>操作</th>
                        </tr>
                        {volist name="arr" id="vo"}
                        <tr>
                            <td>{$vo.id}</td>
                            <td>
                                {if condition="$vo.type == 1"}
                                    投诉
                                {elseif condition="$vo.type ==2"}
                                    建议
                                {/if}
                            </td>
                            <td>{$vo.title|mb_substr=0,20,'utf-8'}</td>
                            <td>{$vo.context|mb_substr=0,50,'utf-8'}</td>
                            <td>
                                <a href="#" value="{$vo.id}" class="a_cz tsjyhh_click">回复</a>
                                <a href="javascript:ajax_delete('{$vo.id}')" class="a_cz">删除</a>
                            </td>
                        </tr>
                        {/volist}
                    </table>
                </div>

                <div class="gg_03_b">
                    <div class="fl">
                        <span>共 <i>{$arr->total()}</i> 条</span><span>每页 <i>{$arr->listRows()}</i> 条</span>
                    </div>
                    <div class="fr">
                        {$arr->render()}
                    </div>
                </div>

            </div>
        </div>

    </div>

</div>

<!--投诉建议-回复弹窗-->
<div class="tsjyhh_fr">
    <div class="ggtcxq_bg"></div>
    <div class="ggtcxq_c">
        <div class="ggtcxq_cfr">
            <div class="ggtcxqc_t">
                <span>回复</span><a href="javascript:void(0);" class="close"></a>
            </div>
            <div class="jgsp_02">
                <form class="ajax_advice_form" action="{:url('basic/ajax_advice_reply')}">
                <p>
                    <span>标题</span>
                    <input name="id" type="hidden" class="jgsp_02_txt reply_id" />
                    <input maxlength="20" name="reply_title" type="text" class="jgsp_02_txt reply_title" placeholder="" />
                </p>
                <p>
                    <span>回复内容</span>
                    <textarea maxlength="50" name="reply_context" rows="1" cols="1" placeholder="" class="reply_context"></textarea>
                </p>
                <p>
                    <span>&nbsp;</span>
                    <input type="button" class="jgsp_02_btn ajax_advice_submit" value="确定" />
                </p>
                </form>
            </div>

        </div>
    </div>
</div>
<script type="text/javascript">
    $(".tsjyhh_click").each(function () {
        $(this).click(function () {
            var id = $(this).attr("value");
            $(".reply_id").val(id);
            $(".tsjyhh_fr").show();
            $(".tsjyhh_fr .ggtcxq_c").css({ "margin-top": "-" + $(".tsjyhh_fr .ggtcxq_c").height() / 2 + "px" });

        });

    });
    $(".tsjyhh_fr .close").click(function () {
        $(".tsjyhh_fr").hide();
        $(".reply_id").val('');
    });
    $(".tsjyhh_fr .ggtcxq_bg").click(function () {
        $(".tsjyhh_fr").hide();
        $(".reply_id").val('');
    });
</script>

<script type="text/javascript">
    $(function(){
        var layer = layui.layer,form = layui.form;
        //添加一级分类
        $(".ajax_advice_submit").click(function(){
            var reply_title = $(".reply_title").val();
            if(reply_title.length > 20){
                layer.msg("回复标题长度不能超过20");
                return;
            }
            var reply_context = $(".reply_context").val();
            if(reply_context.length > 50){
                layer.msg("回复内容长度不能超过50");
                return;
            }
            var url = $('.ajax_advice_form').attr("action")?$('.ajax_advice_form').attr("action"):"{:url()}";
            var data = $('.ajax_advice_form').serialize();
            ajax_psot(url,data);
        });
    })

    function ajax_delete(id) {
        ajax_psot("{:url('basic/ajax_advice_delete')}",{"id":id});
    }

    function ajax_psot(url,data){
        $.ajax({
            url:url,
            type: "POST",//方法类型
            // dataType: "json",//预期服务器返回的数据类型
            data: data,
            success: function (data) {
                if (data.code === 1) {
                    layer.msg("<span style='margin-left: 18px;'>"+data.msg+"</span>",{icon: 1,time:1000},function(){
                        window.location.href=data.url;
                    });
                }else{
                    layer.msg("<span style='margin-left: 18px;'>"+data.msg+"</span>",{icon: 2,time:1000},function(){
                        /*if(data.url){
                            window.location.href=data.url;
                        }else{
                            location.reload();
                        }*/
                    });
                }
            },
            error : function() {
                layer.msg("<span style='margin-left: 18px;'>请求错误,请联系管理员</span>",{icon: 0,time:1000},function(){
                    //location.reload();
                });
            }
        });
    }
</script>


<!-- content -->
{include file="public/foot"}